<?php /* D:\phpStudy\PHPTutorial\WWW\laravel-admin\resources\views/admin/goods/goodsEdit.blade.php */ ?>
<div id="app">
    <section class="content-header">
        <h1>
            <small>商品编辑</small>
        </h1>

    </section>

    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box box-info">
                    <div class="box-header with-border">


                        <div class="box-tools">
                            <div class="btn-group pull-right" style="margin-right: 5px">
                                <a style="margin:0px 5px;" href="/admin/goods/goodsAttr?goods_id=<?php echo e($goods['goods_id'], false); ?>" class="btn btn-sm btn-default" title="规格"> <span class="hidden-xs">规格</span></a>
                                <a style="margin:0px 5px;" href="/admin/goods/sku?goods_id=<?php echo e($goods['goods_id'], false); ?>" class="btn btn-sm btn-default" title="属性"> <span class="hidden-xs">属性</span></a>
                                <a style="margin:0px 5px;" href="/admin/goods/goodsAddImg?goods_id=<?php echo e($goods['goods_id'], false); ?>" class="btn btn-sm btn-default" title="图片"> <span class="hidden-xs">图片</span></a>
                                <a style="margin:0px 5px;" href="/admin/goods/goodsLease?goods_id=<?php echo e($goods['goods_id'], false); ?>}" class="btn btn-sm btn-default" title="租期"> <span class="hidden-xs">租期</span></a>
                            </div>
                        </div>

<span>
    <a class="btn btn-sm btn-primary grid-refresh" title="刷新"><i class="fa fa-refresh"></i><span class="hidden-xs"> 刷新</span></a>
    <a class="btn btn-sm btn-primary" onclick="javascript:history.go(-1);" title="返回"> <span class="hidden-xs"> 返回</span></a>
  </span>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                    <form id="addForm" action="/admin/goods/goodsEdit" method="post" accept-charset="UTF-8" class="form-horizontal" enctype="multipart/form-data" pjax-container>
                        <div class="box-body">
                            <div class="fields-group">

                                <div class="form-group  ">
                                    <label for="supplier_id" class="col-sm-2  control-label">供应商</label>
                                    <div class="col-sm-8">
                                        <input type="hidden" name="supplier_id"/>
                                        <select class="form-control supplier_id" id="supplier_id" style="width: 100%;" name="supplier_id" data-value="" >
                                            <option value=""></option>
                                            <?php if($supplier): ?>
                                                <?php $__currentLoopData = $supplier; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $v): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <option value="<?php echo e($v['id'], false); ?>" ><?php echo e($v['name'], false); ?></option>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            <?php endif; ?>
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group  ">
                                    <label for="brand_id" class="col-sm-2  control-label">品牌名称</label>
                                    <div class="col-sm-8">
                                        <input type="hidden" name="brand_id"/>
                                        <select class="form-control brand_id" id="brand_id" style="width: 100%;" name="brand_id" data-value="" >
                                            <option value=""></option>
                                            <?php if($brand): ?>
                                                <?php $__currentLoopData = $brand; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $v): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <option value="<?php echo e($v['brand_id'], false); ?>" ><?php echo e($v['brand_name'], false); ?></option>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            <?php endif; ?>

                                        </select>
                                    </div>
                                </div>

                                <div class="form-group  ">
                                    <label for="cate_id" class="col-sm-2  control-label">商品分类</label>
                                    <div class="col-sm-8">
                                        <input type="hidden" name="cate_id"/>
                                        <select class="form-control cate_id" id="cate_id" style="width: 100%;" name="cate_id" data-value="" >
                                            <option value=""></option>
                                            <?php if($category): ?>
                                                <?php $__currentLoopData = $category; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $v): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <option value="<?php echo e($v['cate_id'], false); ?>" ><?php echo e($v['level_str'], false); ?><?php echo e($v['cate_name'], false); ?></option>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            <?php endif; ?>

                                        </select>
                                    </div>
                                </div>

                                <div class="form-group  ">
                                    <label for="goods_name" class="col-sm-2  control-label">商品名称</label>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="fa fa-pencil fa-fw"></i></span>
                                            <input type="text" id="goods_name" name="goods_name" value="<?php echo e($goods['goods_name'], false); ?>" class="form-control goods_name" placeholder="输入 商品名称" />
                                        </div>
                                    </div>
                                </div>


                                <div class="form-group  ">
                                    <label for="keywords" class="col-sm-2  control-label">商品关键词</label>
                                    <div class="col-sm-8">
                                        <textarea name="keyword" class="form-control keywords" rows="5" placeholder="输入 商品关键词"  ><?php echo e($goods['keyword'], false); ?></textarea>
                                    </div>
                                </div>

                                <div class="form-group  ">
                                    <label for="detail" class="col-sm-2  control-label">商品描述</label>
                                    <div class="col-sm-8">
                                        <textarea name="detail" class="form-control detail" rows="5" placeholder="输入 商品简介"  ><?php echo e($goods['detail'], false); ?></textarea>
                                    </div>
                                </div>

                                <div class="form-group  ">
                                    <label for="goods_sale_phone" class="col-sm-2  control-label">售后电话</label>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="fa fa-pencil fa-fw"></i></span>
                                            <input type="text" id="goods_name" name="goods_sale_phone" value="<?php echo e($goods['goods_sale_phone'], false); ?>" class="form-control goods_sale_phone" placeholder="输入 售后电话" />
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group  ">
                                    <label for="goods_tenancy_term" class="col-sm-2  control-label">基本租期(月)</label>
                                    <div class="col-sm-8" id="goods_tenancy_term">
                                        <label class="checkbox-inline">
                                            <input type="checkbox" name="goods_tenancy_term[]" value="12" <?php if(in_array(12,$goods['goods_tenancy_term'])): ?> checked <?php endif; ?> class="goods_tenancy_term"  data-value="" />&nbsp;12&nbsp;&nbsp;
                                        </label>
                                        <label class="checkbox-inline">
                                            <input type="checkbox" name="goods_tenancy_term[]" value="11" <?php if(in_array(11,$goods['goods_tenancy_term'])): ?> checked <?php endif; ?> class="goods_tenancy_term"  data-value="" />&nbsp;11&nbsp;&nbsp;
                                        </label>
                                        <label class="checkbox-inline">
                                            <input type="checkbox" name="goods_tenancy_term[]" value="10" <?php if(in_array(10,$goods['goods_tenancy_term'])): ?> checked <?php endif; ?> class="goods_tenancy_term"  data-value="" />&nbsp;10&nbsp;&nbsp;
                                        </label>
                                        <label class="checkbox-inline">
                                            <input type="checkbox" name="goods_tenancy_term[]" value="9" <?php if(in_array(9,$goods['goods_tenancy_term'])): ?> checked <?php endif; ?> class="goods_tenancy_term"  data-value="" />&nbsp;9&nbsp;&nbsp;
                                        </label>
                                        <label class="checkbox-inline">
                                            <input type="checkbox" name="goods_tenancy_term[]" value="8" <?php if(in_array(8,$goods['goods_tenancy_term'])): ?> checked <?php endif; ?> class="goods_tenancy_term"  data-value="" />&nbsp;8&nbsp;&nbsp;
                                        </label>
                                        <label class="checkbox-inline">
                                            <input type="checkbox" name="goods_tenancy_term[]" value="7" <?php if(in_array(7,$goods['goods_tenancy_term'])): ?> checked <?php endif; ?> class="goods_tenancy_term"  data-value="" />&nbsp;7&nbsp;&nbsp;
                                        </label>
                                        <label class="checkbox-inline">
                                            <input type="checkbox" name="goods_tenancy_term[]" value="6" <?php if(in_array(6,$goods['goods_tenancy_term'])): ?> checked <?php endif; ?> class="goods_tenancy_term"  data-value="" />&nbsp;6&nbsp;&nbsp;
                                        </label>
                                        <label class="checkbox-inline">
                                            <input type="checkbox" name="goods_tenancy_term[]" value="5" <?php if(in_array(5,$goods['goods_tenancy_term'])): ?> checked <?php endif; ?> class="goods_tenancy_term"  data-value="" />&nbsp;5&nbsp;&nbsp;
                                        </label>
                                        <label class="checkbox-inline">
                                            <input type="checkbox" name="goods_tenancy_term[]" value="4" <?php if(in_array(4,$goods['goods_tenancy_term'])): ?> checked <?php endif; ?> class="goods_tenancy_term"  data-value="" />&nbsp;4&nbsp;&nbsp;
                                        </label>
                                        <label class="checkbox-inline">
                                            <input type="checkbox" name="goods_tenancy_term[]" value="3" <?php if(in_array(3,$goods['goods_tenancy_term'])): ?> checked <?php endif; ?> class="goods_tenancy_term"  data-value="" />&nbsp;3&nbsp;&nbsp;
                                        </label>
                                    </div>
                                </div>

                                <div class="form-group  ">
                                    <label for="goods_price" class="col-sm-2  control-label">商品价格</label>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <span class="input-group-addon">￥</span>
                                            <input style="width: 120px" type="text" id="goods_price" name="goods_price" value="<?php echo e($goods['goods_price'], false); ?>" class="form-control goods_price" placeholder="输入 商品总价" />
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group  ">
                                    <label for="goods_official_price" class="col-sm-2  control-label">官方价格</label>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <span class="input-group-addon">￥</span>
                                            <input style="width: 120px" type="text" id="goods_official_price" name="goods_official_price" value="<?php echo e($goods['goods_official_price'], false); ?>" class="form-control goods_official_price" placeholder="输入 官方价格" />
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group  ">
                                    <label for="goods_purchase_price" class="col-sm-2  control-label">进货价</label>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <span class="input-group-addon">￥</span>
                                            <input style="width: 120px" type="text" id="goods_purchase_price" name="goods_purchase_price" value="<?php echo e($goods['goods_purchase_price'], false); ?>" class="form-control goods_purchase_price" placeholder="输入 进货价" />
                                        </div>
                                    </div>
                                </div>


                                <div class="form-group  ">
                                    <label for="is_required" class="col-sm-2  control-label">配件费用</label>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <span class="input-group-addon">￥</span>
                                            <input style="width: 120px" type="text" id="goods_installation_charge" name="goods_installation_charge" value="<?php echo e($goods['goods_installation_charge'], false); ?>" class="form-control goods_installation_charge" placeholder="输入 配件费用" />
                                        </div>
                                        <label class="radio-inline">
                                            <input type="radio" name="is_required" value="1" <?php if($goods['is_required']==1): ?> checked <?php endif; ?> class="minimal is_required" checked  />&nbsp;可选&nbsp;&nbsp;
                                        </label>
                                        <label class="radio-inline">
                                            <input type="radio" name="is_required" value="2" <?php if($goods['is_required']==2): ?> checked <?php endif; ?> class="minimal is_required"   />&nbsp;必选&nbsp;&nbsp;
                                        </label>

                                        <input style="margin-top:5px;" type="text" id="goods_installation_show" name="goods_installation_show" value="<?php echo e($goods['goods_installation_show'], false); ?>" class="form-control goods_installation_show" placeholder="输入 配件费用说明" />
                                    </div>
                                </div>


                                <div class="form-group  ">
                                    <label for="is_required" class="col-sm-2  control-label">意外保障费</label>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <span class="input-group-addon">￥</span>
                                            <input style="width: 120px" type="text" id="goods_insurance" name="goods_insurance" value="<?php echo e($goods['goods_insurance'], false); ?>" class="form-control goods_insurance" placeholder="输入 意外保障费" />
                                        </div>
                                        <label class="radio-inline">
                                            <input type="radio" name="is_required_insurance" value="1" <?php if($goods['is_required_insurance']==1): ?> checked <?php endif; ?> class="minimal is_required_insurance" checked  />&nbsp;可选&nbsp;&nbsp;
                                        </label>
                                        <label class="radio-inline">
                                            <input type="radio" name="is_required_insurance" value="2" <?php if($goods['is_required_insurance']==2): ?> checked <?php endif; ?> class="minimal is_required_insurance"   />&nbsp;必选&nbsp;&nbsp;
                                        </label>
                                    </div>
                                </div>


                            </div>
                        </div>
                        <!-- /.box-body -->

                        <div class="box-footer">
                            <?php echo csrf_field(); ?>
                            <input type="hidden" name="goods_id" value="<?php echo e($goods['goods_id'], false); ?>">
                            <div class="col-md-2">
                            </div>
                            <div class="col-md-8">
                                <div class="btn-group pull-right">
                                    <button type="button" onclick="tijiao()" class="btn btn-primary">编辑</button>
                                </div>



                                <div class="btn-group pull-left">
                                    <button type="reset" class="btn btn-warning">重置</button>
                                </div>
                            </div>
                        </div>
                        <!-- /.box-footer -->
                    </form>
                </div>

            </div></div>
    </section>
</div>
<script data-exec-on-popstate>
    $(function () {

        $("#cate_id").val("<?php echo e($goods['cate_id'], false); ?>");
        $("#brand_id").val("<?php echo e($goods['brand_id'], false); ?>");
        $("#supplier_id").val("<?php echo e($goods['supplier_id'], false); ?>");
        $(".is_new").select2({"allowClear":true,"placeholder":{"id":"","text":"是否新上1"}});

        $('.goods_price').inputmask({"alias":"currency","radixPoint":".","prefix":"","removeMaskOnSubmit":true});
        $('.goods_official_price').inputmask({"alias":"currency","radixPoint":".","prefix":"","removeMaskOnSubmit":true});
        $('.goods_purchase_price').inputmask({"alias":"currency","radixPoint":".","prefix":"","removeMaskOnSubmit":true});
        $('.goods_installation_charge').inputmask({"alias":"currency","radixPoint":".","prefix":"","removeMaskOnSubmit":true});
        $('.goods_insurance').inputmask({"alias":"currency","radixPoint":".","prefix":"","removeMaskOnSubmit":true});

        $('.is_putaway.la_checkbox').bootstrapSwitch({
            size:'small',
            onText: 'ON',
            offText: 'OFF',
            onColor: 'primary',
            offColor: 'default',
            onSwitchChange: function(event, state) {
                $(event.target).closest('.bootstrap-switch').next().val(state ? 'on' : 'off').change();
            }
        });
        $("input.goods_img_list").fileinput({"overwriteInitial":true,"initialPreviewAsData":true,"browseLabel":"\u6d4f\u89c8","showRemove":false,"showUpload":false,"dropZoneEnabled":false,"deleteExtraData":{"goods_img_list":"_file_del_","_file_del_":"","_token":"Kq6b1qbgSwE02ACOgZOsO9QeD99PSWROQgk10d1w","_method":"PUT"},"deleteUrl":"http:\/\/www.laras.com\/admin\/goods\/","allowedFileTypes":["image"]});

        $("input.goods_order_thumbnail").fileinput({"overwriteInitial":true,"initialPreviewAsData":true,"browseLabel":"\u6d4f\u89c8","showRemove":false,"showUpload":false,"dropZoneEnabled":false,"deleteExtraData":{"goods_img_list":"_file_del_","_file_del_":"","_token":"Kq6b1qbgSwE02ACOgZOsO9QeD99PSWROQgk10d1w","_method":"PUT"},"deleteUrl":"http:\/\/www.laras.com\/admin\/goods\/","allowedFileTypes":["image"]});

        $('.after-submit').iCheck({checkboxClass:'icheckbox_minimal-blue'}).on('ifChecked', function () {
            $('.after-submit').not(this).iCheck('uncheck');
        });

        //刷新
        $('.grid-refresh').on('click', function() {
            $.pjax.reload('#pjax-container');
            toastr.success('刷新成功 !');
        });
    });
    function tijiao(){
        var data=new FormData($("#addForm")[0]);
        $.ajax({
            url:"/admin/goods/goodsEdit",
            type:'post',
            data:data,
            dataType:'json',
            processData: false,
            contentType: false,
            success:function(m){
                //toastr.error(m.message);
                if(m.status==1){
                    swal(m.message, '', 'success');
                }else{
                    swal(m.message, '', 'error');
                }
            }
        });
    }
</script>